import Highcharts from "highcharts";

/**
 * 折线图配置
 * @param id ID名称
 * @param categories  x轴数据
 * @param series Y轴数据
 */
export const chartLine = (id,categories,series)=>{
    var chart = Highcharts.chart(id, {
        chart: {
            animation: false,
            panning: false, // 禁止放大
            pinchType: false, // 禁用手势操作
            style: {
                fontSize: '12px',
            }
        },
        credits: {enabled: false},
        accessibility: {
            enabled: false
        },
        title: {
            floating: true,
            text: ''
        },
        xAxis:{
            categories:categories,
            crosshair: true,
            lineColor: '#F3F4F5',
            labels: {
                y:20,
                style: {
                    fontSize: "10px",
                    color: 'rgba(165, 166, 173, 1)',
                },
                step:2
            },
        },
        yAxis: {
            gridLineColor: '#F9F9FA',
            labels: {
                style: {
                    fontSize: "12px",
                    color: 'rgba(165, 166, 173, 1)',
                }
            },
            title: {
                enabled: false,
                text: 'values'
            }
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'middle'
        },
        plotOptions: {
            series: {
                label: {
                    connectorAllowed: false
                },
                // pointStart: 2010
            }
        },
        series:series,
        responsive: {
            rules: [{
                condition: {
                    maxWidth: 500
                },
                chartOptions: {
                    legend: {
                        layout: 'horizontal',
                        align: 'center',
                        verticalAlign: 'top'
                    }
                }
            }]
        }
    });
}